﻿using System.Collections.Generic;
using AbstractBugTracker;
using SmartAssembly;
using Utilities;

namespace Engine.Buggets
{
    internal abstract class FilterBuggetBase<TBug> : IBugget<TBug>
        where TBug : class, IBug
    {
        public IEnumerable<Tuple<ProcessedReport, TBug>> Run(ProcessedReport processedReport, TBug bug)
        {
            if (IncludePredicate(processedReport, bug))
            {
                yield return new Tuple<ProcessedReport, TBug>(processedReport, bug);
            }
            else
            {
                yield break;
            }
        }

        protected abstract bool IncludePredicate(ProcessedReport processedReport, TBug bug);
    }
}
